<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" href="<%=basePath%>favicon.ico" />

<script>
	var _provinceId = '';
	var isLogin = 'false' == 'true';
</script>

<title>商城 触屏版-登录</title>
<link rel="stylesheet" href="<%=basePath%>css/common/normalize.css">
<link rel="stylesheet" href="<%=basePath%>css/common/iconfont.css">
<link rel="stylesheet" href="<%=basePath%>/css/user/login.css">
</head>
<body>
	<div class="m-wrapper">

		<jsp:include page="header_member.jsp"></jsp:include>

		<div class="content box-tab" id="box-main">
			<span class="clear"></span>
			<div class="pad30" id="step1" style="display: block;">
				<div class="tinput">
					<i class="icon-font icon-people licon d3"></i> <i
						class="icon-font ricon d3 icon_close"></i> <input class="pinput"
						type="text" id="phone" value="" name="phone" placeholder="手机号">
				</div>
				<div class="tinput">
					<i class="icon-font icon-lock licon d3 "></i> <input class="pinput"
						type="password" id="code" name="code" placeholder="请输入验证码">
				</div>

				<a class="logbtn" href="javascript:void(0);" onclick="getcode()">获取验证码</a>
				<a class="logbtn" href="javascript:void(0);" onclick="next()">下一步</a>
				<span class="clear"></span>
			</div>
			<div class="pad30" id="step2" style="display: none;">
				<div class="tinput">
					<i class="icon-font icon-people licon d3"></i> <i
						class="icon-font ricon d3 icon_close"></i> <input class="pinput"
						type="text" id="username" value="" name="username"
						placeholder="请输入用户名">
				</div>
				<div class="tinput">
					<i class="icon-font icon-lock licon d3 "></i> <input class="pinput"
						type="text" id="email" name="email" placeholder="请输入邮箱">
				</div>
				<div class="tinput">
					<i class="icon-font icon-lock licon d3 "></i> <input class="pinput"
						type="password" id="password" name="password" placeholder="请输入密码">
				</div>
				<a class="logbtn" id="memberLogin" href="javascript:void(0);">注册</a>
				<a href="javascript:void(0);" class="logbtn submiting"
					style="display: none;">快速注册中...</a> <span class="clear"></span>
			</div>
		</div>

		<div class="tc_loading">
			<img src="<%=basePath%>/img/loading.gif" width="28px" height="28px">
			<div>加载中…</div>
		</div>
		<!--tab category:end-->

		<jsp:include page="footer.jsp"></jsp:include>

	</div>

	<style>
.tc_loading {
	z-index: 9998;
	width: 36%;
	height: 60px;
	text-align: center;
	border-radius: 5px;
	position: fixed;
	top: 50%;
	left: 50%;
	margin-top: -35px;
	margin-left: -18%;
	font-size: 14px;
	color: #fff;
	background-color: rgba(0, 0, 0, .7);
	padding-top: 10px;
	display: none;
}
</style>

	<input id="type" type="hidden" value="${method}">

	<script type="text/javascript" src="<%=basePath%>js/zepto.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/util.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/head.js"></script>

	<script type="text/javascript">

	var isLogin = false;
	var params = G.util.url.getArguments();
	$('.mobpay a').attr('href', '/mobile/member/toMemberRegistSms.html?returnUrl=' + encodeURIComponent(params.returnUrl));
	if(isLogin && params['returnUrl'])
		location.href = params['returnUrl'];
	
	if(location.href != top.location.href)
		top.location.href = location.href;
	
    // 两周内免登陆flg
    var remPasFlg = true;

    $('#remPas').on('click', function () {
        if(remPasFlg){
            $(this).removeClass('wred');
            $(this).removeClass('icon-checkbox-checked');
            $(this).addClass('icon-unchecked');
            remPasFlg = false;
        }else{
            $(this).addClass('wred');
            $(this).addClass('icon-checkbox-checked');
            $(this).removeClass('icon-unchecked');
            remPasFlg = true;
        }
    });

    $(".pinput").on("keyup", function () {
        if($(this).val()){
            $(this).parent().children(".icon_delete").addClass("icon-close");
            $(this).parent().children(".pinput").removeClass("bred");
//            $("#mobileNum").addClass("bred");
        }else{
            $(this).parent().children(".icon_delete").removeClass("icon-close");
        }
    });

    $(".icon_delete").on("click", function () {
        $(this).removeClass("icon-close");
        $(this).parent().children("input").val("").focus();
        if($(this).next().attr('id') == 'mobileNum'){
        	$('#password').val('');
        }
    });
    
    //注册表单提交
    $("#memberLogin").click(function(){
        if(!checkForm()){
            return false;
        }
        var phone = $("#phone").val();
        var password = $("#password").val();
        var email = $("#email").val();
        var username = $("#username").val();
        var rcode = $("#code").val();
        var data = {
        				username : username,
        				phone: phone,
        				pwd: password,
        				code : rcode,
        				email : email,
		            remPasFlg: remPasFlg,
		            registerType :0
		};
        if($('#imgCaptcha').length > 0)
        	data.validCode = $('#imgCaptcha').val();
        $(this).hide();
        $(".submiting").show();
        $.ajax({
            type: "post",
            url: "<%=basePath%>mobile/register",
            data: data,
            dataType: "json",
            success: function(result) {
                if(result.code == "0000"){
                	//注册成功
                		location.href="<%=basePath%>mobile/user_center";
				} else {
					
				}
			}
		});
	});

		//表单校验
		function checkForm() {
			var mobileNum = $("#phone").val();
			var password = $("#password").val();
			var mobileReg = /^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/;
			var emailReg = /^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$/;

			if (mobileNum == "" || mobileNum == null) {
				$("#mobileNum").addClass("bred");
				alert("用户名不能为空！");
				return false;
			}
			//			if(!mobileReg.test(mobileNum) && !emailReg.test(mobileNum)){
			//				alert("用户名不正确");
			//				return false;
			//			}
			if (password == "" || password == null) {
				$("#password").addClass("bred");
				alert("请输入密码！");
				return false;
			}
			return true;
		}

		//手机号校验
		function isMobileNO(mobileNum) {
			//			var pattern = new RegExp("^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$");
			//			if(!pattern.test(mobileNum)){
			//				$("#mobileNumMsg").text("用户名不正确！");
			//				return false;
			//			}
			//			$("#mobileNumMsg").empty();
			return true;
		}

		//输入框样式
		$(".Login_top>ul>li").on("click", function() {
			var i = $(this).prev().length;
			$("div div.Login_bottom").eq(i).show().siblings().hide();
			$(this).addClass("cur").siblings().removeClass("cur");
			$("#login_errorMsg").text('');
		});
		
		var code="";
		//手机验证码
		function getcode() {
			var phone = $("#phone").val();
			if(phone==""){
				alert("手机号不能为空");
				return;
			}
			$.ajax({
				type : "post",
				url : "<%=basePath%>identify",
				data : "cMob=" + phone,
				success : function(msg) {
					var info = eval('(' + msg + ')');
					if (info.code != "0000") {
						alert(info.information);
					} else {
						code = info.information;
					}
				}
			})
		}

		function next() {
			var phone = $("#phone").val();
			var phonecode = $("#code").val();
			if (phone == "" || phonecode == "") {
				alert("请填写完整信息");
				return;
			}
			if (code != phonecode) {
				alert("验证码不正确");
				return;
			}
			$("#step1").hide();
			$("#step2").show();
		}
	</script>

</body>
</html>